

package cz.results.testperzist.model;

import java.util.List;
import java.util.ArrayList;
import com.db4o.ext.*;
import com.db4o.*;
import com.db4o.types.Db4oCollections;
        

public class Startovka {
    
    private ArrayList<Zavodnik> sl;
    private String nazev;
    
    public Startovka() {
        this.nazev = "";
        sl = new ArrayList();
    }
    
    public Startovka(String nazev) {
        this();
        this.nazev = nazev;
        sl.clear();
    }
    
    public void setNazev(String nazev) {
        this.nazev = nazev;
    }
    
    public String getNazev() {
        return nazev;
    }
    
    public ArrayList getSL() {
        return sl;
    }
    
    public void addZavodnik(Zavodnik zav) {
        sl.add(zav);
    }
    
    public Zavodnik getZavodnik(int index) {
        if ((index < this.sl.size()) && (index >=0)) {
            return sl.get(index);
        } else {
            return new Zavodnik();
        }
    }
    
    public void delZavodnik(int index) {
        if ((index < this.sl.size()) && (index >=0)) {
            sl.remove(index);
        }
    }
    
    void delZavodnik(Zavodnik zavodnik) {
        if (sl.contains(zavodnik)) {
            sl.remove(zavodnik);
        }
        
    }
    
    public void zapStartovka() {
        sl.clear();
    }
    
    public void fillStartovka(int count) {
        this.sl.clear();
        for (int i=0; i<count; i++) {
            addZavodnik(Zavodnik.getTestZavodnik());
        }
    }
    
    public void listStartovka() {
        for (int i=0; i <= sl.size(); i++) {
            System.out.print(sl.get(i).getStc());
            System.out.println(sl.get(i).getJmeno());
        }
    }
    
    public void objectOnNew(ObjectContainer con)  {
        System.out.println("Startovka onNew... ");
    }
}
